home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / rprint_1 / rtf.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-07-08  |  21.2 KB  |  614 lines

  1. VERSION 5.00
  2. Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "COMCTL32.OCX"
  3. Object = "{3B7C8863-D78F-101B-B9B5-04021C009402}#1.2#0"; "RICHTX32.OCX"
  4. Begin VB.Form RichText 
  5.    BackColor       =   &H80000005&
  6.    Caption         =   "Form1"
  7.    ClientHeight    =   8460
  8.    ClientLeft      =   -870
  9.    ClientTop       =   2130
  10.    ClientWidth     =   11190
  11.    FillColor       =   &H000000FF&
  12.    LinkTopic       =   "Form1"
  13.    MDIChild        =   -1  'True
  14.    ScaleHeight     =   8460
  15.    ScaleWidth      =   11190
  16.    WindowState     =   2  'Maximized
  17.    Begin ComctlLib.Toolbar bar 
  18.       Align           =   1  'Align Top
  19.       Height          =   420
  20.       Left            =   0
  21.       Negotiate       =   -1  'True
  22.       TabIndex        =   1
  23.       Tag             =   "noprint"
  24.       Top             =   0
  25.       Width           =   11190
  26.       _ExtentX        =   19738
  27.       _ExtentY        =   741
  28.       ButtonWidth     =   609
  29.       ButtonHeight    =   582
  30.       AllowCustomize  =   0   'False
  31.       Wrappable       =   0   'False
  32.       Appearance      =   1
  33.       ImageList       =   "ImageList1"
  34.       _Version        =   327682
  35.       BeginProperty Buttons {0713E452-850A-101B-AFC0-4210102A8DA7} 
  36.          NumButtons      =   23
  37.          BeginProperty Button1 {0713F354-850A-101B-AFC0-4210102A8DA7} 
  38.             Object.ToolTipText     =   "Print"
  39.             Object.Tag             =   ""
  40.             ImageIndex      =   1
  41.             Object.Width           =   35
  42.          EndProperty
  43.          BeginProperty Button2 {0713F354-850A-101B-AFC0-4210102A8DA7} 
  44.             Object.ToolTipText     =   "Preview"
  45.             Object.Tag             =   ""
  46.             ImageIndex      =   15
  47.          EndProperty
  48.          BeginProperty Button3 {0713F354-850A-101B-AFC0-4210102A8DA7} 
  49.             Object.ToolTipText     =   "Open File"
  50.             Object.Tag             =   ""
  51.             ImageIndex      =   3
  52.          EndProperty
  53.          BeginProperty Button4 {0713F354-850A-101B-AFC0-4210102A8DA7} 
  54.             Object.ToolTipText     =   "New"
  55.             Object.Tag             =   ""
  56.             ImageIndex      =   14
  57.          EndProperty
  58.          BeginProperty Button5 {0713F354-850A-101B-AFC0-4210102A8DA7} 
  59.             Object.ToolTipText     =   "Save"
  60.             Object.Tag             =   ""
  61.             ImageIndex      =   2
  62.          EndProperty
  63.          BeginProperty Button6 {0713F354-850A-101B-AFC0-4210102A8DA7} 
  64.             Object.ToolTipText     =   "Font Color"
  65.             Object.Tag             =   ""
  66.             ImageIndex      =   17
  67.          EndProperty
  68.          BeginProperty Button7 {0713F354-850A-101B-AFC0-4210102A8DA7} 
  69.             Object.ToolTipText     =   "Bold"
  70.             Object.Tag             =   ""
  71.             ImageIndex      =   4
  72.          EndProperty
  73.          BeginProperty Button8 {0713F354-850A-101B-AFC0-4210102A8DA7} 
  74.             Object.ToolTipText     =   "Underline"
  75.             Object.Tag             =   ""
  76.             ImageIndex      =   6
  77.          EndProperty
  78.          BeginProperty Button9 {0713F354-850A-101B-AFC0-4210102A8DA7} 
  79.             Object.ToolTipText     =   "Italic"
  80.             Object.Tag             =   ""
  81.             ImageIndex      =   5
  82.          EndProperty
  83.          BeginProperty Button10 {0713F354-850A-101B-AFC0-4210102A8DA7} 
  84.             Object.ToolTipText     =   "Undo"
  85.             Object.Tag             =   ""
  86.             ImageIndex      =   18
  87.          EndProperty
  88.          BeginProperty Button11 {0713F354-850A-101B-AFC0-4210102A8DA7} 
  89.             Object.Tag             =   ""
  90.             Style           =   4
  91.             Object.Width           =   30
  92.             MixedState      =   -1  'True
  93.          EndProperty
  94.          BeginProperty Button12 {0713F354-850A-101B-AFC0-4210102A8DA7} 
  95.             Object.ToolTipText     =   "Align Left"
  96.             Object.Tag             =   ""
  97.             ImageIndex      =   7
  98.          EndProperty
  99.          BeginProperty Button13 {0713F354-850A-101B-AFC0-4210102A8DA7} 
  100.             Object.ToolTipText     =   "Center"
  101.             Object.Tag             =   ""
  102.             ImageIndex      =   8
  103.          EndProperty
  104.          BeginProperty Button14 {0713F354-850A-101B-AFC0-4210102A8DA7} 
  105.             Object.ToolTipText     =   "Align Right"
  106.             Object.Tag             =   ""
  107.             ImageIndex      =   9
  108.          EndProperty
  109.          BeginProperty Button15 {0713F354-850A-101B-AFC0-4210102A8DA7} 
  110.             Object.Tag             =   ""
  111.             Style           =   4
  112.             Object.Width           =   30
  113.             MixedState      =   -1  'True
  114.          EndProperty
  115.          BeginProperty Button16 {0713F354-850A-101B-AFC0-4210102A8DA7} 
  116.             Object.ToolTipText     =   "Copy"
  117.             Object.Tag             =   ""
  118.             ImageIndex      =   12
  119.          EndProperty
  120.          BeginProperty Button17 {0713F354-850A-101B-AFC0-4210102A8DA7} 
  121.             Object.ToolTipText     =   "Cut"
  122.             Object.Tag             =   ""
  123.             ImageIndex      =   11
  124.          EndProperty
  125.          BeginProperty Button18 {0713F354-850A-101B-AFC0-4210102A8DA7} 
  126.             Object.ToolTipText     =   "Paste"
  127.             Object.Tag             =   ""
  128.             ImageIndex      =   13
  129.          EndProperty
  130.          BeginProperty Button19 {0713F354-850A-101B-AFC0-4210102A8DA7} 
  131.             Object.ToolTipText     =   "Search"
  132.             Object.Tag             =   ""
  133.             ImageIndex      =   10
  134.          EndProperty
  135.          BeginProperty Button20 {0713F354-850A-101B-AFC0-4210102A8DA7} 
  136.             Object.ToolTipText     =   "Close"
  137.             Object.Tag             =   ""
  138.             ImageIndex      =   16
  139.          EndProperty
  140.          BeginProperty Button21 {0713F354-850A-101B-AFC0-4210102A8DA7} 
  141.             Object.Tag             =   ""
  142.             Style           =   4
  143.             Object.Width           =   2445
  144.             MixedState      =   -1  'True
  145.          EndProperty
  146.          BeginProperty Button22 {0713F354-850A-101B-AFC0-4210102A8DA7} 
  147.             Object.Tag             =   ""
  148.             Style           =   3
  149.             MixedState      =   -1  'True
  150.          EndProperty
  151.          BeginProperty Button23 {0713F354-850A-101B-AFC0-4210102A8DA7} 
  152.             Object.Tag             =   ""
  153.             Style           =   4
  154.             Object.Width           =   1000
  155.             MixedState      =   -1  'True
  156.          EndProperty
  157.       EndProperty
  158.       BorderStyle     =   1
  159.       Begin VB.ComboBox FontNames 
  160.          Height          =   315
  161.          Left            =   6330
  162.          Sorted          =   -1  'True
  163.          TabIndex        =   3
  164.          Top             =   30
  165.          Width           =   2340
  166.       End
  167.       Begin VB.ComboBox FontSizes 
  168.          Height          =   315
  169.          Left            =   8730
  170.          Style           =   2  'Dropdown List
  171.          TabIndex        =   2
  172.          Top             =   15
  173.          Width           =   915
  174.       End
  175.    End
  176.    Begin RichTextLib.RichTextBox Rich 
  177.       Height          =   6720
  178.       Left            =   915
  179.       TabIndex        =   0
  180.       Top             =   735
  181.       Width           =   8730
  182.       _ExtentX        =   15399
  183.       _ExtentY        =   11853
  184.       _Version        =   393217
  185.       BackColor       =   16777215
  186.       BorderStyle     =   0
  187.       ScrollBars      =   2
  188.       DisableNoScroll =   -1  'True
  189.       BulletIndent    =   100
  190.       Appearance      =   0
  191.       RightMargin     =   7000
  192.       TextRTF         =   $"Rtf.frx":0000
  193.    End
  194.    Begin ComctlLib.ImageList ImageList1 
  195.       Left            =   540
  196.       Top             =   7635
  197.       _ExtentX        =   1005
  198.       _ExtentY        =   1005
  199.       BackColor       =   -2147483643
  200.       ImageWidth      =   16
  201.       ImageHeight     =   16
  202.       MaskColor       =   12632256
  203.       _Version        =   327682
  204.       BeginProperty Images {0713E8C2-850A-101B-AFC0-4210102A8DA7} 
  205.          NumListImages   =   18
  206.          BeginProperty ListImage1 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  207.             Picture         =   "Rtf.frx":00FD
  208.             Key             =   ""
  209.          EndProperty
  210.          BeginProperty ListImage2 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  211.             Picture         =   "Rtf.frx":020F
  212.             Key             =   ""
  213.          EndProperty
  214.          BeginProperty ListImage3 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  215.             Picture         =   "Rtf.frx":0321
  216.             Key             =   ""
  217.          EndProperty
  218.          BeginProperty ListImage4 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  219.             Picture         =   "Rtf.frx":0433
  220.             Key             =   ""
  221.          EndProperty
  222.          BeginProperty ListImage5 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  223.             Picture         =   "Rtf.frx":0545
  224.             Key             =   ""
  225.          EndProperty
  226.          BeginProperty ListImage6 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  227.             Picture         =   "Rtf.frx":0657
  228.             Key             =   ""
  229.          EndProperty
  230.          BeginProperty ListImage7 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  231.             Picture         =   "Rtf.frx":0769
  232.             Key             =   ""
  233.          EndProperty
  234.          BeginProperty ListImage8 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  235.             Picture         =   "Rtf.frx":087B
  236.             Key             =   ""
  237.          EndProperty
  238.          BeginProperty ListImage9 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  239.             Picture         =   "Rtf.frx":098D
  240.             Key             =   ""
  241.          EndProperty
  242.          BeginProperty ListImage10 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  243.             Picture         =   "Rtf.frx":0A9F
  244.             Key             =   ""
  245.          EndProperty
  246.          BeginProperty ListImage11 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  247.             Picture         =   "Rtf.frx":0BB1
  248.             Key             =   ""
  249.          EndProperty
  250.          BeginProperty ListImage12 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  251.             Picture         =   "Rtf.frx":0CC3
  252.             Key             =   ""
  253.          EndProperty
  254.          BeginProperty ListImage13 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  255.             Picture         =   "Rtf.frx":0DD5
  256.             Key             =   ""
  257.          EndProperty
  258.          BeginProperty ListImage14 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  259.             Picture         =   "Rtf.frx":0EE7
  260.             Key             =   ""
  261.          EndProperty
  262.          BeginProperty ListImage15 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  263.             Picture         =   "Rtf.frx":1429
  264.             Key             =   ""
  265.          EndProperty
  266.          BeginProperty ListImage16 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  267.             Picture         =   "Rtf.frx":196B
  268.             Key             =   ""
  269.          EndProperty
  270.          BeginProperty ListImage17 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  271.             Picture         =   "Rtf.frx":1C85
  272.             Key             =   ""
  273.          EndProperty
  274.          BeginProperty ListImage18 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  275.             Picture         =   "Rtf.frx":1F9F
  276.             Key             =   ""
  277.          EndProperty
  278.       EndProperty
  279.    End
  280. Attribute VB_Name = "RichText"
  281. Attribute VB_GlobalNameSpace = False
  282. Attribute VB_Creatable = False
  283. Attribute VB_PredeclaredId = True
  284. Attribute VB_Exposed = False
  285. Dim SearchStr As String
  286. Const EM_UNDO = &HC7
  287. Private Type CHOOSECOLOR
  288.   lStructSize As Long
  289.   hWndOwner As Long
  290.   hInstance As Long
  291.   rgbResult As Long
  292.   lpCustColors As String
  293.   Flags As Long
  294.   lCustData As Long
  295.   lpfnHook As Long
  296.   lpTemplateName As String
  297. End Type
  298. Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (ofn As OPENFILENAME) As Boolean
  299. Private Declare Function GetSaveFileName Lib "comdlg32.dll" Alias "GetSaveFileNameA" (ofn As OPENFILENAME) As Boolean
  300. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
  301. Private Type OPENFILENAME
  302.     lStructSize As Long
  303.     hWndOwner As Long
  304.     hInstance As Long
  305.     strFilter As String
  306.     strCustomFilter As String
  307.     nMaxCustFilter As Long
  308.     NFilterIndex As Long
  309.     strFile As String
  310.     nMaxFile As Long
  311.     strFileTitle As String
  312.     nMaxFileTitle As Long
  313.     strInitialDir As String
  314.     strTitle As String
  315.     Flags As Long
  316.     nFileOffset As Integer
  317.     nFileExtension As Integer
  318.     strDefExt As String
  319.     lCustData As Long
  320.     lpfnHook As Long
  321.     lpTemplateName As String
  322. End Type
  323.  Const EM_GETMODIFY = &HB8
  324.  Const EM_SETMODIFY = &HB9
  325.  Const OFN_READONLY = &H1
  326.  Const OFN_OVERWRITEPROMPT = &H2
  327.  Const OFN_HIDEREADONLY = &H4
  328.  Const OFN_NOCHANGEDIR = &H8
  329.  Const OFN_SHOWHELP = &H10
  330.  Const OFN_NOVALIDATE = &H100
  331.  Const OFN_ALLOWMULTISELECT = &H200
  332.  Const OFN_EXTENSIONDIFFERENT = &H400
  333.  Const OFN_PATHMUSTEXIST = &H800
  334.  Const OFN_FILEMUSTEXIST = &H1000
  335.  Const OFN_CREATEPROMPT = &H2000
  336.  Const OFN_SHAREAWARE = &H4000
  337.  Const OFN_NOREADONLYRETURN = &H8000
  338.  Const OFN_NOTESTFILECREATE = &H10000
  339.  Const OFN_NONETWORKBUTTON = &H20000
  340.  Const OFN_NOLONGNAMES = &H40000
  341.  Const OFN_EXPLORER = &H80000
  342.  Const OFN_NODEREFERENCELINKS = &H100000
  343.  Const OFN_LONGNAMES = &H200000
  344. Dim UndoRich As RichTextBox
  345. Dim Changed As Boolean
  346. Dim RPFileName As String
  347. Private Declare Function ChooseColorAPI Lib "comdlg32.dll" Alias "ChooseColorA" (pChoosecolor As CHOOSECOLOR) As Long
  348. Private Function RoboFileOpen(FrHd As Long, _
  349.                             Optional ByVal OpenDialog, _
  350.                             Optional ByRef Flags, _
  351.                             Optional ByVal InitDir, _
  352.                             Optional ByVal FileName, _
  353.                             Optional ByVal BoxTitle, _
  354.                             Optional ByVal Filters, _
  355.                             Optional ByVal DefaultFilter, _
  356.                             Optional ByVal DefaultExt _
  357.                             ) As Integer
  358. ' OpenDialog: False = Open, True = Save
  359. ' Flags: Standard api flag constants. (modified by reference)
  360.     Dim dlg As OPENFILENAME
  361.     Dim ret As Boolean
  362.     Dim n As Integer
  363.    Dim Ieshno As String, StringFile As String, Est As String
  364.     On Error Resume Next
  365.     Const BufferLen As Integer = 512
  366.     If IsMissing(Flags) Then Flags = sjmOFN_HIDEREADONLY
  367.     If IsMissing(InitDir) Then InitDir = CurDir
  368.     If IsMissing(FileName) Then FileName = ""
  369.     If Not OpenDialog Then BoxTitle = "Open -" Else BoxTitle = "Save -"
  370.     BoxTitle = BoxTitle + "Roboprint  " + RPFileName
  371.     If IsMissing(Filters) Then Filters = "Text Files (*.txt)|*.txt|RichText Files (*.rtf)|*.rtf" ' "Rtf Files (*.rtf);Text Files (*.txt)"
  372.     If IsMissing(DefaultFilter) Then DefaultFilter = 2
  373.     If IsMissing(DefaultExt) Then DefaultExt = ""
  374.     For n = 1 To Len(Filters)
  375.         If Mid$(Filters, n, 1) = "|" Then Mid$(Filters, n) = vbNullChar
  376.     Next
  377.     With dlg
  378.         .lStructSize = Len(dlg)
  379.         .hWndOwner = FrHd
  380.         .strFilter = Filters
  381.         .NFilterIndex = DefaultFilter
  382.         .strFile = RPFileName
  383.         .nMaxFile = BufferLen
  384.         .strTitle = BoxTitle
  385.         .Flags = Flags
  386.         .strDefExt = DefaultExt
  387.         .strInitialDir = InitDir
  388.         .nMaxCustFilter = BufferLen
  389.         .strCustomFilter = String$(BufferLen, vbNullChar)
  390.         .strFile = RPFileName + String$(40, vbNullChar)
  391.     End With
  392.     RoboFileOpen = 1
  393.     If OpenDialog Then
  394.         ret = GetSaveFileName(dlg)
  395.     Else
  396.         ret = GetOpenFileName(dlg)
  397.     End If
  398.     Ieshno = dlg.strCustomFilter
  399.     If ret Then
  400.     i = InStr(1, dlg.strFile, Chr$(0), vbTextCompare)
  401.         StringFile = Left(dlg.strFile, Len(dlg.strFile))
  402.        
  403.         StringFile = Trim(StringFile)
  404.         i = InStr(1, dlg.strFile, ".", vbTextCompare)
  405.        Ieshno = Left(StringFile, i - 1)
  406.      
  407.         StringFile = Left(StringFile, Len(Ieshno) + 4)
  408.         StringFile = Right(StringFile, 3)
  409.         If StringFile <> "txt" And StringFile <> "rtf" Then
  410.          n = MsgBox(StringFile + " is a invalid extension", vbAbortRetryIgnore, "File Name Error")
  411.          RoboFileOpen = n
  412.          Exit Function
  413.          End If
  414.          RoboFileOpen = 1
  415.         Ieshno = Ieshno + "." + StringFile
  416.         Ieshno = Dir(Ieshno)
  417.         If Ieshno <> "" Then
  418.         If OpenDialog Then
  419.         Rich.SaveFile Ieshno
  420.         RPFileName = Ieshno
  421.         Else
  422.         Rich.LoadFile Ieshno
  423.         RPFileName = Ieshno
  424.         End If
  425.         Rich.Refresh
  426.         Exit Function
  427.         
  428.         End If
  429.         RoboFileOpen = 1
  430.     End If
  431. End Function
  432. Private Function ShowColorDialog() As Long
  433.   Dim cc As CHOOSECOLOR
  434.   Dim Custcolor(16) As Long
  435.   Dim lReturn As Long
  436.   Dim CustomColors(0 To 63) As Byte
  437. For i = 0 To 63
  438.   CustomColors(i) = 128
  439.   Select Case j
  440.     Case 0
  441.      CustomColors(i) = 255 'red, 0 to 255
  442.      Case 1
  443.      CustomColors(i) = 255 'green, 0 to 255
  444.     Case 2
  445.       CustomColors(i) = 128 'blue, 0 to 255
  446.     Case 3
  447.       CustomColors(i) = 0   'intensity, 0 to 1
  448.       j = -1
  449.   End Select
  450.   j = j + 1
  451.   cc.lStructSize = Len(cc)
  452.   cc.hWndOwner = Me.hwnd
  453.   cc.hInstance = 0
  454.   cc.lpCustColors = StrConv(CustomColors, vbUnicode)
  455.   cc.Flags = 0
  456.   lReturn = ChooseColorAPI(cc)
  457. If lReturn <> 0 Then
  458. ShowColorDialog = cc.rgbResult  'return the color
  459.     ShowColorDialog = -1
  460. End If
  461. End Function
  462. Private Sub bar_ButtonClick(ByVal Button As ComctlLib.Button)
  463. Dim tempColor As Long
  464. Dim Res As Integer
  465. Select Case Button.Index
  466. Case 1
  467. SampleMdi.Roboprint1.LVPrint
  468. Case 2
  469. SampleMdi.Roboprint1.Preview
  470. Case 3
  471. Changed = SendMessage(Rich.hwnd, EM_GETMODIFY, 0, 0)
  472. If Changed Then
  473. Res = MsgBox("Save Change to the file " + RPFileName, vbYesNoCancel, "Roboprint")
  474. If Res = 2 Then Exit Sub
  475. If Res = 6 Then
  476. Res = 4
  477. Do While Res = 4
  478. Res = RoboFileOpen(Me.hwnd, True)
  479. If Res = 3 Then Exit Sub
  480. End If
  481. End If
  482. RoboFileOpen Me.hwnd, False
  483. SendMessage Rich.hwnd, EM_SETMODIFY, False, 0
  484. Case 4
  485. Changed = SendMessage(Rich.hwnd, EM_GETMODIFY, 0, 0)
  486. If Not Changed Then
  487. Rich.TextRTF = ""
  488. Res = 4
  489. Do While Res = 4
  490. Res = RoboFileOpen(Me.hwnd, True)
  491. If Res = 3 Then Exit Sub
  492. End If
  493. Rich.TextRTF = ""
  494. SendMessage Rich.hwnd, EM_SETMODIFY, False, 0
  495. Case 5
  496. RoboFileOpen Me.hwnd, True
  497. SendMessage Rich.hwnd, EM_SETMODIFY, False, 0
  498. Case 6
  499.  tempColor = ShowColorDialog()
  500.   Rich.SelColor = tempColor
  501.   If tempColor < 0 Then Exit Sub
  502. Case 8
  503. Rich.SelUnderline = Not Rich.SelUnderline
  504. bar.Buttons(8).MixedState = Rich.SelUnderline
  505. Case 9
  506. Rich.SelItalic = Not Rich.SelItalic
  507. bar.Buttons(9).MixedState = Rich.SelItalic
  508. Case 7
  509. Rich.SelBold = Not Rich.SelBold
  510. bar.Buttons(7).MixedState = Rich.SelBold
  511. Case 10
  512. SendMessage Rich.hwnd, EM_UNDO, 0, 0
  513. Case 12
  514. Rich.SelAlignment = 0
  515. Case 13
  516. Rich.SelAlignment = 2
  517. Case 14
  518. Rich.SelAlignment = 1
  519. Case 15
  520. Rich.SelAlignment = 1
  521. Case 19
  522. SearchStr = InputBox("Search String", "Roboprint", SearchStr)
  523. SearchString
  524. Case 16
  525. Rich.SetFocus
  526. SendKeys "^c" '
  527. Case 17
  528. Rich.SetFocus
  529. SendKeys "^x"
  530. Case 18
  531. Rich.SetFocus
  532. SendKeys "^v"
  533. Case 20
  534. Unload Me
  535. End Select
  536. End Sub
  537. Private Sub fontnames_Click()
  538. On Error Resume Next
  539. Rich.SelFontName = FontNames.Text
  540. Rich.SetFocus
  541. End Sub
  542. Private Sub Command4_Click()
  543. RoboFileOpen Me.hwnd
  544. End Sub
  545. Private Sub FontSizes_Click()
  546. On Error Resume Next
  547. Rich.SelFontSize = Val(FontSizes)
  548. Rich.SetFocus
  549. End Sub
  550. Private Sub Form_KeyPress(KeyAscii As Integer)
  551. If KeyCode = F3 Then SearchString
  552. End Sub
  553. Private Sub Form_Load()
  554. Dim i As Integer, Sizes As Integer
  555. On Error Resume Next
  556. For i = 0 To Printer.FontCount
  557. FontNames.AddItem Printer.Fonts(i)
  558. Next i
  559. Sizes = 8
  560. For i = 0 To 4
  561. FontSizes.AddItem Str$(Sizes)
  562. Sizes = Sizes + 1
  563. Next i
  564. Sizes = Sizes + 1
  565. For i = 5 To 12
  566. FontSizes.AddItem Str$(Sizes)
  567. Sizes = Sizes + 2
  568. Next i
  569. FontSizes.AddItem 36
  570. FontSizes.AddItem 48
  571. FontSizes.AddItem 72
  572. SendMessage Rich.hwnd, EM_SETMODIFY, False, 0
  573.  RPFileName = App.Path + "\" + "Roboprint.rtf"
  574.  Rich.LoadFile RPFileName
  575. End Sub
  576. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  577. Dim Res As Integer
  578. Changed = SendMessage(Rich.hwnd, EM_GETMODIFY, 0, 0)
  579. If Changed Then
  580. Res = MsgBox("Save the changes in " + RPFileName, vbYesNoCancel)
  581. If Res = 6 Then Rich.SaveFile RPFileName
  582. If Res = 2 Then Cancel = True
  583. End If
  584. End Sub
  585. Private Sub Form_Resize()
  586. On Error Resume Next
  587. Rich.Left = 600
  588. Rich.Top = bar.Top + bar.Height + 600
  589. Rich.Width = Width - 708
  590. Rich.Height = Height - (Rich.Top + 900)
  591. Rich.RightMargin = Rich.Width - 700
  592. End Sub
  593. Private Sub Rich_KeyDown(KeyCode As Integer, Shift As Integer)
  594. If KeyCode = 114 Then SearchString
  595. End Sub
  596. Private Sub Rich_SelChange()
  597. On Error Resume Next
  598. FontNames.Text = Rich.SelFontName
  599. FontSizes.Text = Str$(Rich.SelFontSize)
  600. bar.Buttons(7).MixedState = Rich.SelBold
  601. bar.Buttons(8).MixedState = Rich.SelUnderline
  602. bar.Buttons(9).MixedState = Rich.SelItalic
  603. End Sub
  604. Private Sub SearchString()
  605. Dim seleste As Integer
  606. If Rich.SelStart > 0 Then seleste = 1
  607. seleste = Rich.Find(SearchStr, Rich.SelStart + seleste)
  608. If seleste = -1 Then
  609. MsgBox "Search Text is not Found", , "Robocx"
  610. Rich.SelStart = 0
  611. End If
  612. Rich.SetFocus
  613. End Sub
  614.